package io.xdag.crypt.model;

import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import org.apache.commons.lang3.ArrayUtils;

import javolution.io.Struct;

public class DnetKey extends Struct implements Serializable {

	private static final long serialVersionUID = 1L;

	public Unsigned32[] priv = array(new Unsigned32[256]); 
	public Unsigned32[] pub = array(new Unsigned32[256]); 
	
	private ByteBuffer bb;

	public DnetKey(Byte[] bytes) {
		this.setByteBuffer(bytes);
	}
	
	/**
	 * 初始化对象buffer
	 * @param bytes
	 */
	public void setByteBuffer(Byte[] bytes) {
		byte[] bs = ArrayUtils.toPrimitive(bytes);
		bb = ByteBuffer.wrap(bs);
		bb.order(ByteOrder.LITTLE_ENDIAN);
		this.setByteBuffer(bb, 0);
	}
	
	@Override
	public boolean isPacked() {
		return true;//对齐问题
	}
	
	@Override
	public ByteOrder byteOrder() {
		return ByteOrder.LITTLE_ENDIAN;
	}
	
	public Unsigned32[] getPriv() {
		return priv;
	}
	public void setPriv(Unsigned32[] priv) {
		this.priv = priv;
	}
	public Unsigned32[] getPub() {
		return pub;
	}
	public void setPub(Unsigned32[] pub) {
		this.pub = pub;
	}
	
}
